'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /*
      Add altering commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.createTable('users', { id: Sequelize.INTEGER });
    */
    const { INTEGER, STRING, DATE, JSON } = Sequelize;
    await queryInterface.createTable('trainlines', {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      train_id: {
        type: INTEGER,
        allowNull: false,
      },
      train_name: {
        type: STRING(32),
        allowNull: false,
      },
      station_info: {
        type: JSON,
        allowNull: false,
      },
      created_at: {
        type: DATE,
        allowNull: false,
      },
      updated_at: {
        type: DATE,
        allowNull: false,
      },
    });
  },

  down: async queryInterface => {
    /*
      Add reverting commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.dropTable('users');
    */
    await queryInterface.dropTable('trainlines');
  },
};
